<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class CreateStageTable extends AbstractMigration
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * https://book.cakephp.org/phinx/0/en/migrations.html#the-change-method
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function up()
    {

        $this->table('stage', ['id' => false, 'primary_key' => ['id'], 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci'])
            ->addColumn('id', 'integer', ['identity' => true, 'signed' => false, 'limit' => 11, 'comment' => '自增ID'])
            ->addColumn('name', 'string', ['default' => '', 'limit' => 128, 'comment' => '模板名称(阶段)'])
            ->addColumn('type', 'enum', ['values' => 'standard_meeting,standard_review,default', 'default' => 'default', 'comment' => '模板类型:standard_meeting 标准会议,standard_review 标准审核'])
            ->addColumn('tenant_id', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '租户ID'])
            ->addColumn('order_number', 'integer', ['signed' => false, 'default' => 1, 'limit' => 11, 'comment' => '排序'])
            ->addColumn('step_category_id', 'string', ['default' => '', 'limit' => 128, 'comment' => '关联环节id'])
            ->addColumn('ratio_list', 'json', ['null' => true, 'comment' => '修改比例列表'])
            ->addColumn('created_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建者'])
            ->addColumn('created', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '创建时间'])
            ->addColumn('updated_by', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '编辑者'])
            ->addColumn('updated', 'integer', ['signed' => false, 'default' => 0, 'limit' => 11, 'comment' => '编辑时间'])
            ->create();
    }

    public function down()
    {
        $this->table('stage')->drop()->save();
    }

}
